CREATE FUNCTION func_getDanhSachKhoHang
(
)
RETURNS @temp TABLE
(
 TenHangHoa nvarchar(50),
 SoLuong nvarchar(300)
)
AS
begin
	Declare @TenHangHoa nvarchar(50),
			@SoLuong nvarchar(300),
			@curDanhSachKhoHang Cursor
	SET @curDanhSachKhoHang = CURSOR FOR
		SELECT TenHangHoa, SoLuong = dbo.func_getSoLuongTonKho(STT) from HangHoa
		     
	OPEN @curDanhSachKhoHang
	FETCH NEXT FROM @curDanhSachKhoHang INTO @TenHangHoa, @SoLuong
	WHILE @@FETCH_STATUS = 0
	BEGIN
		Insert @temp values
			(
				@TenHangHoa, 
				@SoLuong
			)
		FETCH NEXT FROM @curDanhSachKhoHang INTO @TenHangHoa, @SoLuong
	END
	
	RETURN	
end